<?php
/**
 * Created by PhpStorm.
 * User: DaibiDaddy
 * Date: 2016/6/3
 * Time: 14:59
 */

namespace App\Setting;

use App\Base\BaseForm;
use App\Base\ViewsInList;
use App\Model\ProvinceModel;

class TimeLineSetting{

    /*手动获取的配置项*/
    public $catType = "level";//Options:level snake
    public $entityCnName = "资讯";//模块名称
    public $table = "TimeLine";//数据表名称
    public $editKeys = array('id','t1','u1','t2','u2','t3','u3','t4','u4','t5','u5','t6','u6','t7','u7','t8','u8','province_Id');//后台管理列表中可以直接编辑的字段
    public $perPage = 10;//后台管理列表中可以直接编辑的字段
    public $noDelete = [];//不想允许删除的ID 放在这里面[0]表示全部禁止删除

    /*自动获取的配置项*/
    public $bundleName;
    public $entityName;
    public $SettingPath;
    public $entityPath;
    public $entity;
    public $modelPath;
    public $doctrine;
    public $em;

    public function __construct($doctrine)
    {
        $this->bundleName = "App";
        $this->entityName = str_replace("\\","",str_replace("Setting","",str_replace(__NAMESPACE__,"",__CLASS__)));
        $this->SettingPath = __CLASS__;
        //$this->entityPath = str_replace($this->entityName."Entity",$this->entityName,str_replace("Setting","Entity",__CLASS__));
        $this->entityPath = "App\\Entity\\".$this->entityName;
        $this->entity = new $this->entityPath();
        $this->modelPath = str_replace("Setting","Model",__CLASS__);
        $this->doctrine = $doctrine;
        $this->em = $doctrine->getManager();
    }

    public function listConfig()
    {
        $default = array();
        $default["Time_Line AS TimeLine"]["select"] = array('id','t1','u1','t2','u2','t3','u3','t4','u4','t5','u5','t6','u6','t7','u7','t8','u8','province_Id');
        $default["Time_Line AS TimeLine"]["search"] = array('id','t1','u1','t2','u2','t3','u3','t4','u4','t5','u5','t6','u6','t7','u7','t8','u8','province_Id');
        $default["Time_Line AS TimeLine"]["condition"] = array('id','t1','u1','t2','u2','t3','u3','t4','u4','t5','u5','t6','u6','t7','u7','t8','u8','province_Id');
        $default["Time_Line AS TimeLine"]["orderBy"] = array('id','t1','u1','t2','u2','t3','u3','t4','u4','t5','u5','t6','u6','t7','u7','t8','u8','province_Id');

        $join = array();
        $join["Province AS Province"]["on"] = "Province.id = TimeLine.province_Id";
        $join["Province AS Province"]["select"] = array("name");
        $join["Province AS Province"]["search"] = array();
        $join["Province AS Province"]["condition"] = array();
        $join["Province AS Province"]["orderBy"] = array();

        return array(
            "default"   => $default,
            "joins"     => $join,
        );
    }

    public function viewConfig()
    {

    }


    public function formConfig()
    {
        $BaseForm = new BaseForm();
        $ProvinceModel = new ProvinceModel($this->doctrine);
        $data = $ProvinceModel->getAll();
        $data = $ProvinceModel->createSelectFromEntity($data);
        $config["provinceId"] = $BaseForm->select("provinceId","省份",$data);
        $config["t1"] = $BaseForm->datetime("t1","公告时间");
        $config["u1"] = $BaseForm->text("u1","公告链接");
        $config["t2"] = $BaseForm->datetime("t2","报名时间");
        $config["u2"] = $BaseForm->text("u2","报名链接");
        $config["t3"] = $BaseForm->datetime("t3","缴费时间");
        $config["u3"] = $BaseForm->text("u3","缴费链接");
        $config["t4"] = $BaseForm->datetime("t4","打印准考证");
        $config["u4"] = $BaseForm->text("u4","打印链接");
        $config["t5"] = $BaseForm->datetime("t5","考试时间");
        $config["u5"] = $BaseForm->text("u5","考试链接");
        $config["t6"] = $BaseForm->datetime("t6","成绩查询时间");
        $config["u6"] = $BaseForm->text("u6","成绩查询链接");
        $config["t7"] = $BaseForm->datetime("t7","面试时间");
        $config["u7"] = $BaseForm->text("u7","面试链接");
//        $config["t8"] = $BaseForm->text("t8","t8");
//        $config["u8"] = $BaseForm->text("u8","u8");
//        $config["provinceId"] = $BaseForm->text("provinceId","provinceid");
        return $config;
    }
}